﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZLDC.Common.Estate;
using System.Data;
using System.Data.SqlClient;
using ZLDC.Topo.Model.Estate;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Web.UI.HtmlControls;
namespace ZLDC.Topo.BLL.Estate
{
    public class lp_Basis
    {
        public static DataTable CallExcel(string filepath)
        {
            OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filepath + ";Extended Properties=Excel 8.0");
            con.Open();
            string sql = "select * from [Sheet1$]";//选择第一个数据SHEET
            OleDbDataAdapter adapter = new OleDbDataAdapter(sql, con);
            DataTable dt = new DataTable();
            adapter.Fill(dt);
            con.Close();
            con.Dispose();
            return dt;
        }

        public static string SqlQuery(string[] txtName, string TypeName, string[] txtCode, string[] txtPoint, string[] txtRemark, string[] txtNum, string[] txtSort, string[] txtHighest, string[] txtUnit)
        {
            string outmsg = "添加失败";
            int rows = 0;
            string sqlstr = "delete from lp_Basis where TypeName='" + TypeName + "'; ";

            for (int i = 0; i < txtName.Length; i++)
            {
                if ("" != txtName[i])
                {
                    sqlstr += " insert into lp_Basis (TypeName,TypeCode,Name,Point,Remark,Other1,Other2,Other3,Other4,Other5,CreateUser,CreateTime,Url,Whether,Sort,Quantity,dte,Highest,Unit,DeptID) values (";
                    string fk = "0";
                    sqlstr += "'" + TypeName + "','" + txtCode[i] + "','" + txtName[i] + "'," + (txtPoint[i] == "" ? "0" : txtPoint[i]) + ",'" + txtRemark[i] + "'," + "'','','','',''," + "" + _Utility.GetInfoBySession().m_sUserID + "," + "'" + DateTime.Now + "'," + "''," + "0," + "" + (txtSort[i] == "" ? "0" : txtSort[i]) + "," + (txtNum[i] == "" ? "0" : txtNum[i]) + "," + fk + "," + (txtHighest[i] == "" ? "0" : txtHighest[i]) + ",'" + txtUnit[i] + "'," + _Utility.GetInfoBySession().m_sDeptID + ")";
                }
            }
            using (_Database db = new _Database("estate"))
            {
                rows = ZLDC.DAL.Estate.lp_Basis.SqlQuery(sqlstr, db);
            }
            if (rows > 0)
                outmsg = "添加成功！";
            return outmsg;
        }

        public static string GetTB(string sql)
        {
            DataSet ds = new DataSet();
            using (_Database db = new _Database("estate"))
            {
                ds = ZLDC.DAL.Estate.lp_Basis.GetTb(sql, db);
            }
            string ht = "";
            if (null != ds)
            {
                ht += "<div>";
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    ht += "<a href='lp_Basis.aspx?typename=" + ds.Tables[0].Rows[i]["TypeName"] + "'>" + ds.Tables[0].Rows[i]["TypeName"] + "</a>&nbsp;&nbsp;";
                }
                ht += "<a href='lp_Basis.aspx?typename=fk'>显示全部</a>&nbsp;&nbsp;<a href='lp_Basis.aspx'>新增类别</a></div>";
            }
            return ht;
        }

        public static string Execution(string sql)
        {
            string outmsg = "删除失败";
            int rows = 0;
            using (_Database db = new _Database("estate"))
            {
                rows = ZLDC.DAL.Estate.lp_Basis.Execution(sql, db);
            }
            if (rows > 0)
                outmsg = "删除成功！";
            return outmsg;
        }
        /// <summary>
        /// 通用查询返回dataset
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public static DataSet Getds(string sql)
        {
            DataSet ds = new DataSet();
            using (_Database db = new _Database("estate"))
            {
                ds = ZLDC.DAL.Estate.lp_Basis.GetTb(sql, db);
            }
            return ds;
        }

        /// <summary>
        /// 并且 返回当前身份 符合为真
        /// </summary>
        /// <param name="station"></param>
        /// <returns></returns>
        public static bool GetStationbq(string station)
        {
            if (station != "置业顾问" && station != "跑盘员" && station != "业务主任" && station != "合作代理" && station != "高级跑盘员")
            {
                return true;
            }
            return false;
        }

        /// <summary>
        /// 或者 返回当前身份 符合为真
        /// </summary>
        /// <param name="station"></param>
        /// <returns></returns>
        public static bool GetStationhz(string station)
        {
            if (station == "置业顾问" || station == "跑盘员" || station == "业务主任" || station == "合作代理" || station == "高级跑盘员")
            {
                return true;
            }
            return false;
        }

        /// <summary>
        /// 返回查询部门人员的身份 统一调用 sql条件
        /// </summary>
        /// <param name="stationSql"></param>
        /// <returns></returns>
        public static string GetUserStation()
        {
            return "station='置业顾问' or station='跑盘员' or station='业务主任' or station='高级跑盘员' or station='合作代理'";
        }


        /// <summary>
        /// 查询部门人员
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public static DataSet GetDept(string sql)
        {
            string sqlwhere = " select vk.id,user_name,t_id,deptname  from v_usr_link vk left join lp_Configuration_main lc on vk.id=lc.userID where status not in('离职','停薪留职') and dltflg=0 and vk.ID is not null and vk.id !=" + _Utility.GetInfoBySession().m_sUserID + " ";
            if (_Utility.GetInfoBySession().m_sStation == "分行经理")
            {
                sqlwhere += " and (" + GetUserStation() + ") and t_id=" + _Utility.GetInfoBySession().m_sDeptID + "";
            }

            else
            {
                sqlwhere += " and t_id=" + _Utility.GetInfoBySession().m_sDeptID + "";
            }
            if (sql != "")
            {
                sqlwhere += sql;
            }
            sqlwhere += "   group by user_name,vk.id,t_id,deptname";
            // string sqlwhere = " select userid as id ,Other2 as user_name,deptID as t_id from lp_Configuration_main where deptID=" + _Utility.GetInfoBySession().m_sDeptID + " and CONVERT(varchar,createTime,23)='" + DateTime.Now.ToString("yyyy-MM-dd") + "'";
            return ZLDC.Topo.BLL.Estate.lp_Basis.Getds(sqlwhere);
        }

        /// <summary>
        /// 查询最低设置分数
        /// </summary>
        /// <returns></returns>
        public static string Exists_Set()
        {
            string sql = "select top 1 itemValue ";
            sql += "from dbo.t_system_option ";
            sql += "where item='每日量化最低分数' and itemValue>0 and subsidiaryID in (select deptid from dbo.f_GetAllFatherDeptAll(" + _Utility.GetInfoBySession().m_sDeptID + ")) ";
            sql += "order by grade desc ";
            using (_Database db = new _Database("estate"))
            {
                sql = ZLDC.DAL.Estate.lp_Basis.Exists_Set(sql, db);
            }
            return sql;
        }
        /// <summary>
        /// 通用翻页存储过程
        /// </summary>
        /// <param name="tb"></param>
        /// <param name="col"></param>
        /// <param name="colorder"></param>
        /// <param name="orderby"></param>
        /// <param name="collist"></param>
        /// <param name="pagesize"></param>
        /// <param name="page"></param>
        /// <param name="condition"></param>
        /// <param name="pages"></param>
        /// <param name="intResult"></param>
        /// <returns></returns>
        public static DataTable GetTB(string tb, string col, string colorder, int orderby, string collist, int pagesize, int page, string condition, ref int pages, ref int intResult)
        {
            DataTable ds = new DataTable();
            // using (_Database db = new _Database("estate"))
            // {
            ds = ZLDC.DAL.Estate.lp_Basis.lp_list(tb, col, colorder, orderby, collist, pagesize, page, condition, ref pages, ref intResult);
            // }
            return ds;
        }

        /// <summary>
        /// 绑定下拉列表
        /// </summary>
        /// <param name="dropPK"></param>
        /// <param name="text"></param>
        /// <param name="value"></param>
        /// <param name="sql"></param>
        public static void droplist(DropDownList dropPK, string text, string value, string sql)
        {
            DataSet ds = ZLDC.Topo.BLL.Estate.lp_Basis.Getds(sql);
            dropPK.DataSource = ds.Tables[0];
            dropPK.DataTextField = text;
            dropPK.DataValueField = value;
            dropPK.DataBind();
            ListItem item = new ListItem();
            item.Text = "请选择";
            item.Value = "0";
            dropPK.Items.Insert(0, item);

        }
        /// <summary>
        /// 绑定下拉列表
        /// </summary>
        /// <param name="dropPK"></param>
        /// <param name="text"></param>
        /// <param name="value"></param>
        /// <param name="sql"></param>
        public static void droplist(HtmlSelect dropPK, string text, string value, string sql)
        {
            DataSet ds = ZLDC.Topo.BLL.Estate.lp_Basis.Getds(sql);
            dropPK.DataSource = ds.Tables[0];
            dropPK.DataTextField = text;
            dropPK.DataValueField = value;
            dropPK.DataBind();
            ListItem item = new ListItem();
            item.Text = "全部";
            item.Value = "0";
            dropPK.Items.Insert(0, item);

        }

        public static string GetUserName(string user_id)
        {
            string sql = "select  id as userid,t_id as deptid,station,user_name from v_usr_link where  id=" + user_id + "  ";
            DataSet ds = Getds(sql);
            if (rtcount(ds))
            {
                return ds.Tables[0].Rows[0]["user_name"].ToString();
            }
            return "";
        }



        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public static bool Exists(string sql)
        {
            return ZLDC.DAL.Estate.lp_Basis.Exists_sql(sql);
        }

        /// <summary>
        /// 执行SQL 返回受影响的行数
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public static int Execution_sql(string sql)
        {

            return ZLDC.DAL.Estate.lp_Basis.lp_Configuration_main_add(sql);

        }

        /// <summary>
        /// 任务总表 分配任务 空增加一条数据
        /// </summary>
        public static int lp_Configuration_main_add(string sql)
        {
            return ZLDC.DAL.Estate.lp_Basis.lp_Configuration_main_add(sql);
        }



        public static DataTable lp_Report(int typeid, string condition, string deptid)
        {
            int ismanager = 0;  // 0当前用户非查询部门管理者 1当前用户是查询部门管理者
            int isStation = 0;  //  0表示跑盘｜置业 1 表示管理者
            string sessionDeptid = _Utility.GetInfoBySession().m_sDeptID;   // 当前登录者部门ID
            string station = _Utility.GetInfoBySession().m_sStation;        // 职称
            if (_Utility.GetWebConfigSetting("SalesManagerStation").Contains(station))
                isStation = 1;

            string deptlist = ZLDC.Common.BaseUser.UserInfo.getAllChildDept(sessionDeptid, "0");

            // 判断是否是该客的管理者                    
            if (deptlist.Contains(deptid.ToString()))
                ismanager = 1;

            DataTable dt = null;

            using (_Database db = new _Database("estate"))
            {
                dt = ZLDC.DAL.Estate.ReportDAL.p_report_dept_list_table(typeid, condition, db);
            }
            return dt;
        }

        /// <summary>
        /// 返回经理或者总监
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string Deptlist(string type)
        {
            if (type == "" || type == "")
                return "";
            return "";
        }



        #region 公用方法 常用方法


        public static string GetPageLocation()
        {
            return "<script>window.location.href=location.href;</script>";
        }


        /// <summary>
        /// 当前属于哪个城市
        /// </summary>
        /// <returns></returns>
        public static string GetArea()
        {
            return System.Configuration.ConfigurationManager.AppSettings["Area"].ToString();
        }

        /// <summary>
        /// 返回不包含经理 公盘字体
        /// </summary>
        /// <returns></returns>
        public static string GetManagerlh()
        {
            return "<div style=\"width:100%;text-align:center\">不包含经理人和公盘量化数据</div>";
        }

        public static string GetQYPM(string childdept, string deptid, DateTime dt, string userid)
        {
            string deptIdList = childdept;
            string html = "";
            DataSet ds1 = ZLDC.Topo.BLL.Estate.lp_Basis.Getds("select Actual_Goal as Actual_Goal,userID  from lp_Configuration_main where deptid = " + deptid + "  and DATEDIFF(dd, workday, '" + dt.ToString("yyyy-MM-dd") + "') = 0  order by Actual_Goal desc");
            for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
            {
                if (ds1.Tables[0].Rows[i]["Actual_Goal"].ToString() != "0")
                {
                    if (userid == ds1.Tables[0].Rows[i]["userid"].ToString())
                    {

                        html = (i + 1).ToString();
                        break;
                    }
                }
                else
                {
                    return "0";
                }
            }
            return html;
        }

        /// <summary>
        /// 登录权限后访问的
        /// </summary>
        /// <param name="deptid"></param>
        /// <returns></returns>
        public static bool GetJurisdiction(string deptname)
        {
            string sql = "select DeptFullName from t_zlhq_t_s_alldept where Id=" + _Utility.GetInfoBySession().m_sDeptID;
            DataSet ds = ZLDC.Topo.BLL.Estate.lp_Basis.Getds(sql);
            if (rtcount(ds))
            {
                string dept_name = ds.Tables[0].Rows[0][0].ToString();
                string[] deptlist = deptname.Split(',');
                foreach (string item in deptlist)
                {
                    if (dept_name.Contains(item))
                    {
                        return true;

                    }

                }

                return false;

            }
            else
            {
                return false;
            }
            //if (_Utility.GetInfoBySession().m_sDeptID == deptid)
            //{
            //    return true;
            //}
            //else
            //{
            //    return false;
            //}
        }

        /// <summary>
        /// 根据部门ID查出分行经理ID
        /// </summary>
        /// <param name="deptid"></param>
        /// <returns></returns>
        public static string DeptIDGetUserID(string deptid)
        {
            string sql = "select id from v_usr_link where t_id=" + deptid + " and station='分行经理' and status!='离职'";
            DataSet ds = ZLDC.Topo.BLL.Estate.lp_Basis.Getds(sql);
            if (rtcount(ds))
            {
                return ds.Tables[0].Rows[0]["id"].ToString();
            }
            return "";
        }

        /// <summary>
        /// 获取上级所有部门ID
        /// </summary>
        /// <returns></returns>
        public static string GetDeptList(string deptid)
        {
            string sql = "select * from f_GetAllFatherDeptAll(" + deptid + ")";
            DataSet ds = ZLDC.Topo.BLL.Estate.lp_Basis.Getds(sql);
            if (ZLDC.Topo.BLL.Estate.lp_Basis.rtcount(ds))
            {
                string deptlist = "";
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    deptlist += ds.Tables[0].Rows[i][0].ToString() + ",";
                }
                deptlist = deptlist.Replace(deptid, "0");
                return deptlist.Substring(0, deptlist.Length - 1);
            }
            return "0";
        }
        /// <summary>
        /// 获取上级第一个部门ID
        /// </summary>
        /// <returns></returns>
        public static string getdept1(string deptid)
        {
            string sql = "select parent_id from t_zlhq_t_s_alldept  where DltFlg=0 and Id='" + deptid + "' ";
            DataSet ds = ZLDC.Topo.BLL.Estate.lp_Basis.Getds(sql);
            if (rtcount(ds))
            {
                return ds.Tables[0].Rows[0]["parent_id"].ToString();
            }
            return "0";
        }

        /// <summary>
        /// 获取同级部门ID 
        /// </summary>
        /// <returns></returns>
        public static string getdepttjlist(string deptid)
        {
            string sql = "select id as deptid,name as deptname from t_zlhq_t_s_alldept where parent_id=(select parent_id from t_zlhq_t_s_alldept where Id=" + deptid + "  )and DltFlg=0";
            DataSet ds = ZLDC.Topo.BLL.Estate.lp_Basis.Getds(sql);
            if (ZLDC.Topo.BLL.Estate.lp_Basis.rtcount(ds))
            {
                string deptlist = "";
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    deptlist += ds.Tables[0].Rows[i][0].ToString() + ",";
                }
                return deptlist.Substring(0, deptlist.Length - 1);
            }
            return "";
        }

        /// <summary>
        /// 获取部门员工
        /// </summary>
        /// <param name="deptid"></param>
        /// <returns></returns>
        public static string GetDeptUserid(string deptid)
        {

            string sql = "  select userid from v_lp_userDeptSuperior where deptid=" + deptid + "  ";
            DataSet ds = ZLDC.Topo.BLL.Estate.lp_Basis.Getds(sql);
            if (ZLDC.Topo.BLL.Estate.lp_Basis.rtcount(ds))
            {
                string deptlist = "";
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    deptlist += ds.Tables[0].Rows[i][0].ToString() + ",";
                }
                return deptlist.Substring(0, deptlist.Length - 1);
            }
            return "";
        }

        /// <summary>
        /// 获取下级部门 平均分
        /// </summary>
        /// <param name="deptid"></param>
        /// <returns></returns>
        public static string GetDeptxjlist(string deptid)
        {
            string sql = " select id as deptid,name as deptname from t_zlhq_t_s_alldept where parent_id=" + deptid + " and DltFlg=0";
            DataSet ds = ZLDC.Topo.BLL.Estate.lp_Basis.Getds(sql);
            if (ZLDC.Topo.BLL.Estate.lp_Basis.rtcount(ds))
            {
                string deptlist = "";
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    deptlist += ds.Tables[0].Rows[i][0].ToString() + ",";
                }
                return deptlist.Substring(0, deptlist.Length - 1);
            }
            return deptid;
        }

        /// <summary>
        /// 确认是否检查工作 返回勾
        /// </summary>
        /// <param name="isconfirm"></param>
        /// <returns></returns>
        public static string Gettf(object isconfirm)
        {
            string rtstring = "";
            switch (isconfirm.ToString())
            {
                case "1":
                    rtstring = "√";
                    break;
                case "0":
                    rtstring = "×";
                    break;
            }
            return rtstring;
        }

        /// <summary>
        /// 查询ds是否有表 有数据
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        public static bool rtcount(DataSet ds)
        {
            if (ds == null)
            {
                return true;
            }
            else
            {
                if (ds.Tables == null)
                {
                    return true;
                }
                else
                {
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                    else
                    {
                        return false;
                    }
                }

            }
        }

        /// <summary>
        /// 查询是否自己选择和请假
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public static string UserDy(string userid)
        {
            string sql = " select choiceType,leave from lp_Configuration_main where userID=" + userid + " and  DATEDIFF(dd, workday, '" + DateTime.Now.ToString("yyyy-MM-dd") + "') = 1";
            DataSet ds = Getds(sql);
            if (rtcount(ds))
            {

                if (ds.Tables[0].Rows[0]["choiceType"].ToString() == "1")
                {
                    return "(自己选择)";
                }
                if (ds.Tables[0].Rows[0]["leave"].ToString() == "1")
                {
                    return "(请假)";
                }
            }

            return "";
        }

        /// <summary>
        /// 获取上级包括区 营业部 大部的ID和名次
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public static string[] GetDeptExprlist(string userid)
        {
            string[] list = new string[12];
            string sql = "select * from v_lp_userDeptSuperior where userid=" + userid;
            DataSet ds = Getds(sql);
            if (rtcount(ds))
            {
                for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
                {
                    list[i] = ds.Tables[0].Rows[0][i].ToString();
                }
            }
            return list;
        }

        /// <summary>
        /// 根据用户ID 返回区域ID
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public static string expr1(string userid)
        {
            string sql = "select expr1 from v_lp_userDeptSuperior where userid=" + userid;
            DataSet ds = Getds(sql);
            if (rtcount(ds))
            {
                return ds.Tables[0].Rows[0][0].ToString();
            }
            return "0";
        }
        /// <summary>
        /// 根据用户ID 返回区域名称
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public static string expr2(string userid)
        {
            string sql = "select expr2 from v_lp_userDeptSuperior where userid=" + userid;
            DataSet ds = Getds(sql);
            if (rtcount(ds))
            {
                return ds.Tables[0].Rows[0][0].ToString();
            }
            return "0";
        }

        /// <summary>
        ///跟进部门ID ，返回区经 营业部ID
        /// </summary>
        /// <param name="deptid"></param>
        /// <returns></returns>
        public static string GetDepttwo(string deptid)
        {
            string sql = "select expr1,expr3 from v_lp_userDeptSuperior where id=" + deptid;
            DataSet ds = Getds(sql);
            if (rtcount(ds))
            {
                return ds.Tables[0].Rows[0]["expr1"].ToString() + "," + ds.Tables[0].Rows[0]["expr3"].ToString();
            }
            return "0";
        }

        /// <summary>
        /// 根据用户ID 返回营业部ID
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public static string expr3(string userid)
        {
            string sql = "select expr3 from v_lp_userDeptSuperior where userid=" + userid;
            DataSet ds = Getds(sql);
            if (rtcount(ds))
            {
                return ds.Tables[0].Rows[0][0].ToString();
            }
            return "0";
        }

        /// <summary>
        /// 根据用户ID 返回营业部名称
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public static string expr4(string userid)
        {
            string sql = "select expr4 from v_lp_userDeptSuperior where userid=" + userid;
            DataSet ds = Getds(sql);
            if (rtcount(ds))
            {
                return ds.Tables[0].Rows[0][0].ToString();
            }
            return "0";
        }
        /// <summary>
        /// 根据用户ID 返回营业大部
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public static string expr5(string userid)
        {
            string sql = "select expr5 from v_lp_userDeptSuperior where userid=" + userid;
            DataSet ds = Getds(sql);
            if (rtcount(ds))
            {
                return ds.Tables[0].Rows[0][0].ToString();
            }
            return "0";
        }
        /// <summary>
        /// 根据用户ID 返回营业大部名称
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public static string expr6(string userid)
        {
            string sql = "select expr6 from v_lp_userDeptSuperior where userid=" + userid;
            DataSet ds = Getds(sql);
            if (rtcount(ds))
            {
                return ds.Tables[0].Rows[0][0].ToString();
            }
            return "0";
        }
        #endregion

        //在C#后台实现JavaScript的函数escape()的字符串转换
        //些方法支持汉字
        private static string escape(string s)
        {
            StringBuilder sb = new StringBuilder();
            byte[] byteArr = System.Text.Encoding.Unicode.GetBytes(s);

            for (int i = 0; i < byteArr.Length; i += 2)
            {
                sb.Append("%u");
                sb.Append(byteArr[i + 1].ToString("X2"));//把字节转换为十六进制的字符串表现形式

                sb.Append(byteArr[i].ToString("X2"));
            }
            return sb.ToString();

        }

        /// <summary>
        /// 饼图点击的url
        /// </summary>
        /// <param name="typeName"></param>
        /// <returns></returns>
        public static string Get_ChartUrl(string typeName)
        {
            switch (typeName)
            {
                case "客源新增":
                    typeName = "../../AM/Customer_List.aspx?reporttypeid=0";
                    break;
                case "盘源新增":
                    typeName = "../../AM/Housing_List.aspx?reporttypeid=0";
                    break;
                case "有效客源跟进":
                    typeName = "../../AM/CustomerFollowList.aspx?";
                    break;
                case "有效盘源跟进":
                    typeName = "../../AM/HousingFollowList.aspx?flwtype=1";
                    break;
                case "钥匙":
                    typeName = "../../AM/Housing_List.aspx?reporttypeid=20";
                    break;
                case "摆台":
                    typeName = "../../AM/CustomerFollowList.aspx?ftype=" + escape("摆台") + "";
                    break;
                case "成交后服务":
                    typeName = "../../AM/CustomerFollowList.aspx?ftype=" + escape("成交后服务") + "";
                    break;
                case "诚意金":
                    typeName = "../../AM/CustomerFollowList.aspx?ftype=" + escape("诚意金") + "";
                    break;
                case "带看房":
                    //typeName = "../../AM/CustomerFollowList.aspx?ftype=" + escape("带看房") + "";
                    typeName = "~/../../Quantify/Report/lp_ForSale.aspx?ftype=" + escape("带看房") + "";
                    break;
                case "独家委托":
                    typeName = "../../AM/Housing_List.aspx?reporttypeid=2";
                    break;
                case "反签":
                    typeName = "../../AM/Housing_List.aspx?reporttypeid=3";
                    break;
                case "家访":
                    typeName = "../../AM/HousingFollowList.aspx?flwtype=21"; //http: //localhost:41075/AM/HousingFollowList.aspx?salesmanid=20089&addDate1=2012-04-19&addDate2=2012-04-19&flwtype=21
                    break;
                case "自看房":
                    typeName = "../../AM/HousingFollowList.aspx?flwtype=2";
                    break;
                case "网络推广":
                    typeName = "";
                    break;
            }
            return typeName;
        }

        /// <summary>
        /// 饼图点击的url
        /// </summary>
        /// <param name="typeName"></param>
        /// <returns></returns>
        public static string Get_ChartUrl1(string typeName)
        {
            switch (typeName)
            {
                case "客源新增":
                    typeName = "../../AM/Customer_List.aspx?reporttypeid=0";
                    break;
                case "盘源新增":
                    typeName = "../../AM/Housing_List.aspx?reporttypeid=0";
                    break;
                case "有效客源跟进":
                    typeName = "../../AM/CustomerFollowList.aspx?";
                    break;
                case "有效盘源跟进":
                    typeName = "../../AM/HousingFollowList.aspx?flwtype=1";
                    break;
                case "钥匙":
                    typeName = "../../AM/Housing_List.aspx?reporttypeid=20";
                    break;
                case "摆台":
                    typeName = "../../AM/CustomerFollowList.aspx?ftype=" + escape("摆台") + "";
                    break;
                case "成交后服务":
                    typeName = "../../AM/CustomerFollowList.aspx?ftype=" + escape("成交后服务") + "";
                    break;
                case "诚意金":
                    typeName = "../../AM/CustomerFollowList.aspx?ftype=" + escape("诚意金") + "";
                    break;
                case "带看房":
                    typeName = "../../AM/CustomerFollowList.aspx?ftype=" + escape("带看房") + "";
                    //typeName = "~/../../Quantify/Report/lp_ForSale.aspx?ftype=" + escape("带看房") + "";
                    break;
                case "独家委托":
                    typeName = "../../AM/Housing_List.aspx?reporttypeid=2";
                    break;
                case "反签":
                    typeName = "../../AM/Housing_List.aspx?reporttypeid=3";
                    break;
                case "家访":
                    typeName = "../../AM/HousingFollowList.aspx?flwtype=21"; //http: //localhost:41075/AM/HousingFollowList.aspx?salesmanid=20089&addDate1=2012-04-19&addDate2=2012-04-19&flwtype=21
                    break;
                case "自看房":
                    typeName = "../../AM/HousingFollowList.aspx?flwtype=2";
                    break;
                case "网络推广":
                    typeName = "";
                    break;
            }
            return typeName;
        }


        /// <summary>
        /// 返回项目分名称对应的 楼盘字段
        /// </summary>
        /// <param name="BasisName"></param>
        /// <returns></returns>
        public static string Gett_quantification_name(string BasisName)
        {
            switch (BasisName)
            {
                case "钥匙":
                    BasisName = "[key]";
                    break;
                case "家访":
                    BasisName = "visit";
                    break;
                case "客源新增":
                    BasisName = "(newcustomer+mark2)";
                    break;
                case "盘源新增":
                    BasisName = "(newhousing+mark1)";
                    break;
                case "反签":
                    BasisName = "versa";
                    break;
                case "独家委托":
                    BasisName = "only";
                    break;
                case "街霸/派单":
                    BasisName = "handbill";
                    break;
                case "有效盘源跟进":
                    BasisName = "hfollow";
                    break;
                case "有效客源跟进":
                    BasisName = "cfollow";
                    break;
                case "带客看房":
                    BasisName = "(looked+mark3)";
                    break;
                case "自看房":
                    BasisName = "[self]";
                    break;
                case "诚意金":
                    BasisName = "EarnestMoney";
                    break;
                case "摆台":
                    BasisName = "talks";
                    break;
                case "成交后服务":
                    BasisName = "afterservice";
                    break;
            }
            return BasisName;
        }






        /// <summary>
        /// 返回项目分名称对应的 楼盘字段
        /// </summary>
        /// <param name="BasisName"></param>
        /// <returns></returns>
        public static string Gett_quantification_name(string BasisName, string point)
        {
            switch (BasisName)
            {
                case "钥匙":
                    BasisName = "sum([key]*" + point + ")+";
                    break;
                case "家访":
                    BasisName = "sum([visit]*" + point + ")+";
                    break;
                case "客源新增":
                    BasisName = "sum((newcustomer+mark2)*" + point + ")+";
                    break;
                case "盘源新增":
                    BasisName = "sum((newhousing+mark1)*" + point + ")+";
                    break;
                case "反签":
                    BasisName = "sum([versa]*" + point + ")+";
                    break;
                case "独家委托":
                    BasisName = "sum([only]*" + point + ")+";
                    break;
                case "街霸/派单":
                    BasisName = "sum([handbill]*" + point + ")+";
                    break;
                case "有效盘客跟进":
                    BasisName = "sum([hfollow]*" + point + ")+";
                    break;
                case "带客看房":
                    BasisName = "sum((looked+mark3)*" + point + ")+";
                    break;
                case "自看房":
                    BasisName = "sum([self]*" + point + ")+";
                    break;
                case "诚意金":
                    BasisName = "sum([EarnestMoney]*" + point + ")+";
                    break;
                case "摆台":
                    BasisName = "sum([talks]*" + point + ")+";
                    break;
                case "售后服务":
                    BasisName = "sum([afterservice]*" + point + ")+";
                    break;
            }
            return BasisName;
        }
    }
}
